﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SchemaMonitor.json
{
    public class CDictError : CDict
    {
        //Data
        public string Message;
        public string Type;
        public int Code;

        public int SubCode;
        public string UserTitle;
        public string UserMessage;
        public string FbTraceId;

        //Constructor
        public CDictError(Exception ex) : this(ex.Message) { }
        public CDictError(string json) : this(ToDict(json).AsDict("error")) { }
        public CDictError(Dictionary<string, object> dict) : base(dict)
        {
            Type = AsStr("type");
            Message = AsStr("message");
            Code = AsInt("code");

            SubCode = AsInt("error_subcode");
            UserTitle = AsStr("error_user_title");
            UserMessage = AsStr("error_user_msg");
            FbTraceId = AsStr("fbtrace_id");
        }
    }
}
